{
{% if 'esMasters' in group_names and (groups['esMasters'] | length) >= 3 %}
  "server": true,
  "bootstrap_expect": 3,
  "retry_join": [
    {%- for item in groups['esMasters'] if item != ansible_nodename -%}
      "{{ hostvars[item]['bind_address'] }}"{%- if loop.nextitem is defined -%},{%- endif -%}
    {%- endfor -%}
  ],
  "ui": true,
  "client_addr": "0.0.0.0",
{% elif 'esMasters' not in group_names and (groups['esMasters'] | length) >= 3 %}
  "server": false,
  "retry_join": [
    {%- for item in groups['esMasters'] -%}
      "{{ hostvars[item]['bind_address'] }}"{%- if loop.nextitem is defined -%},{%- endif -%}
    {%- endfor -%}
  ],
{% else %}
  "server": true,
  "bootstrap": true
{% endif %}
{# ---------------- #}
  "datacenter": "{{ consul_dc_name }}",
  "data_dir": "/var/consul",
  "encrypt": "{{ consul_key }}",
  "log_level": "WARN",
  "enable_syslog": true,
  "enable_script_checks": true,
  "bind_addr": "{{ bind_address }}",
  "addresses": {
    "dns": "0.0.0.0"
  }
}
